<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <style>
        .box{
            width: 500px;
            height: 500px;
            background-color: #f00;
        }
        .a{
            width: 300px;
            height: 300px;
            background-color: #ff0;
        }
        .b{
            width: 200px;
            height: 200px;
            background-color: #f0f;
        }
    </style>
</head>
<body>

    <div class="box">
        <div class="a">
            <div class="b"></div>
        </div>
    </div>

    <script>



        var oBox = document.querySelector('.box') ;
        var oA = document.querySelector('.a') ;
        var oB = document.querySelector('.b') ;


        // 默认为事件冒泡
        oBox.addEventListener('click' , function() {
            console.log('box');
        })

        oA.addEventListener('click' , function(e) {
            var ev = e || event ;
            // 事件对象阻止事件冒泡
            if(ev.stopPropagation) {
                v.stopPropagation() ;
            } else {
                // 低版本IE取消事件冒泡
                ev.cancelBubble = true ;
            }
            console.log('a');
        })

        oB.addEventListener('click' , function(e) {
            e.stopPropagation() ;   // 阻止事件冒泡
            console.log('b');
        })


    </script>
    
</body>
</html>